<template>
  <div class="icons">
    <swiper>
      <swiper-slide class="icon-swiper" v-for="(page,index) of pages" :key="index">
        <div class="icon" v-for="item of page" :key="item.id">
          <img
            class="icon-img"
            :src="item.imgUrl"
            alt
          />
          <p class="icon-desc">{{item.desc}} </p>
        </div>
      </swiper-slide>
    </swiper>
  </div>
</template>

<script>
export default {
  name: "HomeIcon",
  props:{
    list:Array
  },
  data() {
    return {
     
    }
  },
  computed:{
    pages(){
      const pages = []
      this.list.forEach((item,index) => {
        const page = Math.floor(index/8)
        if(!pages[page]){
          pages[page] = []
        }
        pages[page].push(item)
      })
      return pages
    }
  }
};
</script>

<style>
.icons {
  width: 100%;
  border-bottom: .05rem solid #ccc ;
}
.icon-swiper{
  display: flex;
  flex-wrap: wrap;
}
.icon {
  overflow: hidden;
  height: 0.8rem;
  width: 0.9rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.icon-img {
  width: 0.55rem;
}
.icon-desc {
  font-size: 0.15rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
</style>